<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改开课计划')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-plan-edit" th:object="${tbKaikePlan}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">开课名称：</label>
                <div class="col-sm-8">
                    <input id="kaikeName" name="kaikeName" th:field="*{kaikeName}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">课程名称：</label>
                <div class="col-sm-8">
                       <select th:field="*{courseId}" th:remove="all-but-first" class="form-control" name="courseId" style="width:476px;">
                        <option th:each="list : ${list}" th:value="${list.id}" th:text="${list.courseName}"></option>
                       </select>
                </div>
            </div>

            <!--<div class="form-group">
                <label class="col-sm-3 control-label">学时：</label>
                <div class="col-sm-8">
                    <input name="stutime" id="stuTime" th:field="*{stutime}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">学分：</label>
                <div class="col-sm-8">
                    <input name="stuscore" id="stuScore" th:field="*{stuscore}" class="form-control" type="text" required>
                </div>
            </div>-->

            <div class="form-group" style="display: flex;text-align: center;">
                <label class="col-sm-3 control-label">开课教师：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="courseTeacher" id="courseTeacher" th:with="teacherNames=${@user.getUserName()}" th:field="*{courseTeacher}">
                        <option th:each="teacherName : ${teacherNames}" th:text="${teacherName.userName}" th:value="${teacherName.loginName}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">学生类别：</label>
                <div class="col-sm-8">
                    <select name="stutype" th:field="*{stutype}" class="form-control m-b" th:with="type=${@dict.getType('sys_stu_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">面向群体：</label>
                <div class="col-sm-8">
                    <select name="facegroup" class="form-control m-b" th:with="type=${@dict.getType('sys_profession')}">
                        <option value="0">全部</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">开课人数：</label>
                <div class="col-sm-8 d-flex" style="display: flex;align-items: center">
                    <input name="stulownumber" th:field="*{stulownumber}" class="form-control" type="text" style="width:100px;" value="0" required>
                    <label>&nbsp;&nbsp;~&nbsp;&nbsp;</label>
                    <input name="stumaxnumber" th:field="*{stumaxnumber}" class="form-control" type="text" style="width:100px;" required>
                </div>
            </div>

            <div class="form-group">


                <label class="col-sm-3 control-label">学年：</label>
                <div class="col-sm-8" style="width:500px;display: flex;">
                    <select name="stuterm" class="form-control m-b" th:with="type=${@term.selectTbTermList()}">
                        <option th:each="term : ${type}" th:text="${term.schoolYear +'学年  第'+term.term+'学期'+' (' + #dates.format(term.startTime, 'yyyy-MM-dd') + '--' + #dates.format(term.endTime, 'yyyy-MM-dd')+') '}" th:value="${term.id}"></option>
                    </select>
                    <!--<select name="stuYear" th:field="*{stuYear}" class="form-control m-b" th:with="type=${@term.selectTbTermList()}">
                        <option th:each="term : ${type}" th:text="${term.schoolYear}" th:value="${term.id}"></option>
                    </select>
                    <select name="stutype" th:field="*{stuterm}" class="form-control m-b" th:with="type=${@dict.getType('sys_period')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>-->
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">上课周：</label>
                <div class="col-sm-8 d-flex" style="display: flex;align-items: center">
                    <input name="classloweek" th:field="*{classlowweek}" class="form-control" type="text" style="width:100px;" required>
                    <label>&nbsp;&nbsp;~&nbsp;&nbsp;</label>
                    <input name="classmaxweek" th:field="*{classmaxweek}" class="form-control" type="text" style="width:100px;" required>
                </div>
            </div>

            <!--<div class="form-group">
                <label class="col-sm-3 control-label">上课时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input id="courseTime" name="courseTime" th:value="${#dates.format(tbKaikePlan.courseTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>-->

            <div class="form-group">
                <label class="col-sm-3 control-label">上课时间：</label>
                <div class="col-sm-8"  style="display: flex;align-items: center">
                    <select name="courseWeektime" th:field="*{courseWeektime}" class="form-control m-b" th:with="type=${@dict.getType('sys_week')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                    <select name="firstCouretime" th:field="*{firstCouretime}" class="form-control m-b" th:with="type=${@classTime.selectTbClassTimeList()}">
                        <option th:each="classtime : ${type}" th:text="${classtime.section}" th:value="${classtime.id}"></option>
                    </select>
                    <select name="lastCouretime" th:field="*{lastCouretime}" class="form-control m-b" th:with="type=${@classTime.selectTbClassTimeList()}">
                        <option th:each="classtime : ${type}" th:text="${classtime.section}" th:value="${classtime.id}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group">    
                <label class="col-sm-3 control-label">上课地点：</label>
                <div class="col-sm-8">
                    <input id="courseAddress" name="courseAddress" th:field="*{courseAddress}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "website/kaikeplan";
        $("#form-plan-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            /*var kaikeName = $("#kaikeName").val();
            var courseTeacher = $("#courseTeacher").val();
            var courseTime = $("#courseTime").val();
            var courseAddress = $("#courseAddress").val();
            if(kaikeName ==null || kaikeName==""){
                $.modal.alertWarning("课程名称不能为空");
                return false;
            }if(courseTeacher ==null || courseTeacher==""){
                $.modal.alertError("开课教室不能为空");
                return false;
            }if(courseTime ==null || courseTime==""){
                $.modal.alertError("上课时间不能为空");
                return false;
            }if(courseAddress ==null || courseAddress==""){
                $.modal.alertError("上课地点不能为空");
                return false;
            }*/
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-plan-edit').serialize());
            }
        }

        $("input[name='courseTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>